import java.sql.*
import groovy.sql.Sql

class Example {
    static void main(String[] args){
        // creating a connection to the database
        def sql = Sql.newInstance('jdbc:mysql://localhost:3306/demo?useSSL=false','root','1234','com.mysql.jdbc.Driver')

        sql.eachRow('SELECT * from Employee') {
            row -> println ([row.FIRST_NAME,row.LAST_NAME,row.age,row.sex,row.INCOME])
        }

        sql.close()
    }
}